<template>
  <div>
    <!-- 历史记录 -->
    <div class="history">
      <div class="top">
        <div class="title">历史记录</div>
        <van-icon name="delete-o" @click="delClearhistory" />
      </div>
      <div class="down">
        <van-tag
          class="mytag"
          :data-item="item"
          v-for="(item, index) in historyKeywordList"
          :key="index"
          color="#ccc"
          plain
          type="primary"
          @click="goProduct(item)"
          >{{ item }}</van-tag
        >
      </div>
    </div>
    <!-- 热门 -->
    <div class="history">
      <div class="top">
        <div class="title">热门搜索</div>
      </div>
      <div class="down">
        <van-tag
          class="mytag"
          :data-item="item.keyword"
          :color="item.is_hot == 1 ? '#f00' : '#ccc'"
          plain
          type="primary"
          v-for="(item, index) in hotKeywordList"
          :key="index"
          @click="goProduct(item.keyword)"
          >{{ item.keyword }}</van-tag
        >
      </div>
    </div>
  </div>
</template>

<script>
import { Toast } from 'vant';
import { GetClearhistoryList } from "../../request/api";
export default {
  props: ["historyKeywordList", "hotKeywordList"],
  data() {
    return {};
  },
  methods: {
    delClearhistory() {
      GetClearhistoryList().then((res) => {
        // console.log(res);
        Toast.success("删除成功");
        this.$emit("list")
      });
    },
    goProduct(val){
      this.$emit("fn",val)
    }
  },
};
</script>
 
<style lang = "less" scoped>
.history {
  padding: 10px;
  background: #fff;
  margin-bottom: 20px;
  .top {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .down {
    .mytag {
      margin-right: 10px;
      margin-bottom: 5px;
    }
    van-tag:nth-last-child(1) {
      color: red;
    }
  }
}
</style>